package com.wsd.dao;

import com.wsd.domain.NormalLoan;
import com.wsd.domain.OverdueLoan;
import com.wsd.domain.RepayPlan;
import com.wsd.domain.RepaymentPlan;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;

@Repository
public interface RepaymentPlanMapper {
    int deleteByPrimaryKey(Long planId);

    int insert(RepaymentPlan record);

    int insertSelective(RepaymentPlan record);

    RepaymentPlan selectByPrimaryKey(Long planId);

    int updateByPrimaryKeySelective(RepaymentPlan record);

    int updateByPrimaryKey(RepaymentPlan record);

    /**
     * 根据订单编号查找还款记录信息
     *
     * @param loanId
     * @return
     */
    List<RepaymentPlan> selectRepaymentPlanByLoanId(@Param("loanId") long loanId);

    List<Long> findNormalGroup();//查找所有正常贷款id

    List<Long> findSOverdueGroup();//查找所有短期逾期贷款id

    List<Long> findLOverdueGroup();//查找所有长期逾期贷款id

    BigDecimal findNormalInterest();//返回正常贷款应收总利息

    BigDecimal findSOverInterest();//返回短期贷款应收总利息

    BigDecimal findLOverInterest();//返回长期贷款应收总利息

    // BigDecimal findOverInterest(List<Long> list);//返回逾期贷款应收总利息

    BigDecimal sumRepayInterest(List<Long> list);//正常贷款已经还清本金的利息总和。

    //BigDecimal sumOverRepayInterest(List<Long> list);//逾期贷款已经还清本金的利息总和。

    BigDecimal sumSOverdueMoney();//短期逾期贷款逾期总金额：用户逾期贷款的总金额

    BigDecimal sumLOverdueMoney();//长期逾期贷款逾期总金额：用户逾期贷款的总金额

    BigDecimal sumSOverdueInterest();//短期逾期贷款逾期总利息

    BigDecimal sumLOverdueInterest();//长期逾期贷款逾期总利息

    List<NormalLoan> findNormalLoanForm(int start,int num);//获取正常贷款报表（用户信息未填入）

    List<OverdueLoan> findSOverLoanForm(int start,int num);

    List<OverdueLoan> findLOverLoanForm(int start,int num);

    List<OverdueLoan> findLOverLoanForm();

    List<RepaymentPlan> findNewOverduePlans(); //查询新增逾期还款计划记录  --by WangYu
    List<RepaymentPlan> findAllOverduePlans(); //查询所有逾期还款计划记录  --by WangYu
    Long countNormalLoanForm();

    Long countSOverLoanForm();

    Long countLOverLoanForm();

    /**
     * 根据订单编号查询某次贷款的所有还款记录详细
     *
     * @param loanId
     * @return
     */
    List<RepaymentPlan> selectRepaymentPlanByLoanIdAndStatus(@Param("loanId") long loanId);
    /**
     * 批量插入还款信息
     */
    int insertRepaymentPlans(List<RepayPlan> repayPlans);
}
